import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set_node_cls from "@dfeidao/atom-web/ui/set-node-cls";

import set from '@dfeidao/atom-web/local/set';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import p002 from './p002';
import p003 from './p003';
import p004 from './p004';
import p005 from './p005';

export default async function a001(fd: IFeidaoAiBrowserComponent, val: { val1: { ne: string }, risk_po_name_no: string, risk_po_type_no: string }) {


	// // 隐藏主页面
	// const ff = fd.data.node.querySelector<HTMLDListElement>('[data-zname="zong"]');
	// ff.setAttribute('class', 'display-n');

	// todo
	if (!val.val1.ne) {
		const no = val.risk_po_type_no as string;
		set(fd, 'no', no);
		console.log("右侧添加===》", no);
	} else {
		const no = val.val1.ne as string;
		set(fd, 'no', no);
		console.log("右侧添加===222》", no);
	}



	const no1 = val.risk_po_name_no as string;

	console.log("有什么？？？", no1);


	set(fd, 'val', val);



	console.log("右侧添加++》", val);


	render(fd, val, p002, 'p002', 'inner');
	render(fd, val, p001, 'p001', 'inner');

	const pn = fd.data.params['page-no'] as string;
	let pno = 1;
	if (pn) {
		pno = parseInt(pn, 10);
	}


	const res = await nodejs<{ res: Array<{}>; c: number; }>('risk_point/zj-000004/s001', { risk_po_name_no: no1, page_no: 1 });


	console.log('右侧右侧--》', res);

	if (res) {
		render(fd, res.res, p003, 'p003', 'inner');
		render(fd, { page_no: 1, total: res.c[0].n }, p004, 'p004', 'inner');
	} else {
		render(fd, '', p005, 'p005', 'inner');
	}

	// 显示右侧添加弹出框
	const d = fd.data.node.querySelector<HTMLDivElement>('[data-name="yadd1"]');
	set_node_cls(d, 'display-n', false);
}
